import { defineStore } from 'pinia';
import type * as Type from './type';

const useFilmReadLeft = defineStore('frPageLeft', {
  persist: true,
  state: (): Type.FilmReadLeft => ({
    showLesionList: []
  }),
  actions: {
    // 派发state
    setState(partial: Partial<Type.FilmReadLeft>) {
      this.$patch(partial);
    },
    // 是否展示所有病灶
    isShowAllLesion() {
      return this.showLesionList;
    },
    // 设置当前病灶列表
    setLesionList(dataList: Type.NidusList[]) {
      this.setState({ showLesionList: Object.assign([], dataList) });
    },
    // 设置当前点击的哪一项
    setCurrentLesion(id: number = 0) {
      return this.showLesionList.filter(item => item.disease.id === id)[0];
    }
  }
})

export default useFilmReadLeft;